(function(window){
	var doc = document;
	var $ = function(str){
		if(!typeof str =="string")return;
		return doc.getElementById(str);
	}
	var $class = function(str,context){
		var context = context||doc.body;
		return context.getElementByClassName(str);
	}
	var _bindEvent = function(){
		var table = $("table");
		table.addEventListener("click",_executeButBindEvent,false);
	}
	
	//执行代码,计算时间差
	var _execute = function(opt){
		var star=new Date().getTime();
		
		eval(opt.code);
		
		var end=new Date().getTime();
		
		$("time-"+opt.key).innerHTML=end-star;
		
	}
	var _executeButBindEvent = function(event){
		var target = event.target;
		
		if(target.className.indexOf("btnrun")!=-1){
			var codeId = target.getAttribute("aim");
			var code = $(codeId).innerText;
			_execute({code:code,key:codeId});
			
		}
		
	}
	
	var init =function(){
		_bindEvent();
	}
	 
	init();
	
})(window);
